package com.example.moviegroup.activity;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Toast;

import com.example.moviegroup.R;

/**
 * Created by walymin-love on 2015/11/18.
 */
public class MoreActivity extends Activity implements View.OnClickListener {
    private RelativeLayout rl_clear,rl_gengxin,rl_banggui,rl_help,rl_about,rl_server;
    ImageView tuisong;
    boolean flag = true;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_more);
        iniView();
        setListener();
        initData();
    }

    public void iniView() {
        tuisong = (ImageView) findViewById(R.id.more_iv_tuisong2);
        rl_clear = (RelativeLayout) findViewById(R.id.more_clear);
        rl_about = (RelativeLayout) findViewById(R.id.more_about);
        rl_banggui = (RelativeLayout) findViewById(R.id.more_banggui);
        rl_gengxin = (RelativeLayout) findViewById(R.id.more_gengxin);
        rl_help = (RelativeLayout) findViewById(R.id.more_help);
        rl_server = (RelativeLayout) findViewById(R.id.more_kefu);
    }

    public void setListener() {
        rl_about.setOnClickListener(this);
        rl_clear.setOnClickListener(this);
        rl_gengxin.setOnClickListener(this);
        rl_server.setOnClickListener(this);
        rl_help.setOnClickListener(this);
        rl_banggui.setOnClickListener(this);
        tuisong.setOnClickListener(this);
    }

    public void initData() {
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.more_about:
                Intent intent = new Intent(MoreActivity.this,AboutActivity.class);
                startActivity(intent);
                break;
            case R.id.more_help:
                Intent intent1 = new Intent(MoreActivity.this,HelpActivituy.class);
                startActivity(intent1);
                break;
            case R.id.more_gengxin:
                Toast.makeText(this,"已经是最新版本！",Toast.LENGTH_SHORT).show();
                break;
            case R.id.more_clear:
                AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                dialog.setTitle("是否清除缓存？");
                dialog.setNegativeButton("Yes", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                    }
                }).setPositiveButton("NO", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                    }
                });
                dialog.show();
                break;
            case R.id.more_banggui:
                Intent intent2 = new Intent(MoreActivity.this,BangGuiActivity.class);
                startActivity(intent2);
                break;
            case R.id.more_kefu:
                Intent intent3 = new Intent(MoreActivity.this,ServerActivity.class);
                startActivity(intent3);
                break;
            case R.id.more_iv_tuisong2:
                if(flag){
                    tuisong.setImageResource(R.mipmap.more_tuisong_on);
                    flag = false;
                }else {
                    tuisong.setImageResource(R.mipmap.more_tuisong_off);
                    flag = true;
                }
                break;
        }
    }
}
